package sqlHelp;

import java.util.ArrayList;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


public class DatabaseHelper extends SQLiteOpenHelper {
	private static final int DB_VERSION = 1;
	final static String dbName = "honDB";
	static final String heroTable = "Hero";
	static final String name = "HeroName";
	static final String stats = "HeroStats";
	static final String guideString = "HeroGuide";
	static final String heroAv = "HeroAvatar";
	SQLiteDatabase myDb = null;
	public DatabaseHelper(Context ctx) {
		super(ctx, dbName, null, DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		
		db.execSQL("CREATE TABLE " + heroTable + " ("+"_id INTEGER PRIMARY KEY," + name
				+ " TEXT(25) , " + stats + " TEXT(25)," + guideString
				+ " TEXT(25)," + heroAv + " TEXT(25) )");
		insertHero(db,"valkyrie","stat 1","C:/here is the guide","valkyrie");
		insertHero(db,"Predator","stat 1","C:/here is the guide","predator");
		insertHero(db,"corrupteddisciple","stat 1","C:/here is the guide","corrupteddisciple");
		
	
		
	}

	public void insertHero(SQLiteDatabase db, String _name, String _stats,
			String _guide, String _pic) {

		ContentValues cv = new ContentValues();
		cv.put(name, _name);
		cv.put(stats, _stats);
		cv.put(guideString, _guide);
		cv.put(heroAv, _pic);
		db.insert(heroTable,dbName , cv);
		
	}

	public ArrayList<String> getAllOfColumn(String columnName, Context context, SQLiteDatabase myDb ) {
		ArrayList<String> result = new ArrayList<String>();
		Cursor c = myDb.rawQuery("Select " + columnName + " from Hero", null);

		c.getColumnIndex("HeroName");

		c.moveToFirst();
		while (c.isAfterLast() == false) {
			result.add(c.getString(0));
			c.moveToNext();
		}
		return result;
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}
}
